<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="position,css," />





  <link rel="alternate" href="/atom.xml" title="Da'sBlog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="绝对定位一直用起来非常方便，直接脱离文本流。偶然发现它还有个超强的功能。竟然可以撑开盒子宽高。 对外默认情况下，看代码；盒子如果设置   宽高后   设置绝对定位,bottom为0会自动抵底部。123456789101112131415161718192021222324252627282930313233343536&amp;lt;html lang=&quot;en&quot;&amp;gt;&amp;lt;head&amp;gt;">
<meta name="keywords" content="position,css">
<meta property="og:type" content="article">
<meta property="og:title" content="position:absolute-top,right,bottom,left为0使用">
<meta property="og:url" content="http://sunhao.win/articles/css-top-right-bootom-left-zero.html">
<meta property="og:site_name" content="Da&#39;sBlog">
<meta property="og:description" content="绝对定位一直用起来非常方便，直接脱离文本流。偶然发现它还有个超强的功能。竟然可以撑开盒子宽高。 对外默认情况下，看代码；盒子如果设置   宽高后   设置绝对定位,bottom为0会自动抵底部。123456789101112131415161718192021222324252627282930313233343536&amp;lt;html lang=&quot;en&quot;&amp;gt;&amp;lt;head&amp;gt;">
<meta property="og:image" content="http://ojlt0g866.bkt.clouddn.com/blog/20170226/194602705.png">
<meta property="og:image" content="http://ojlt0g866.bkt.clouddn.com/blog/20170226/195039804.png">
<meta property="og:image" content="http://ojlt0g866.bkt.clouddn.com/blog/20170226/201040072.png">
<meta property="og:image" content="http://ojlt0g866.bkt.clouddn.com/blog/20170226/201912871.png">
<meta property="og:image" content="http://ojlt0g866.bkt.clouddn.com/blog/20170226/202907572.png">
<meta property="og:updated_time" content="2017-02-26T12:29:38.723Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="position:absolute-top,right,bottom,left为0使用">
<meta name="twitter:description" content="绝对定位一直用起来非常方便，直接脱离文本流。偶然发现它还有个超强的功能。竟然可以撑开盒子宽高。 对外默认情况下，看代码；盒子如果设置   宽高后   设置绝对定位,bottom为0会自动抵底部。123456789101112131415161718192021222324252627282930313233343536&amp;lt;html lang=&quot;en&quot;&amp;gt;&amp;lt;head&amp;gt;">
<meta name="twitter:image" content="http://ojlt0g866.bkt.clouddn.com/blog/20170226/194602705.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"right","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://sunhao.win/articles/css-top-right-bootom-left-zero.html"/>





  <title> position:absolute-top,right,bottom,left为0使用 | Da'sBlog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?b8432f1a5c5c27d6783c25569df4b270";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










  
  
    
  

  <div class="container one-collumn sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Da'sBlog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
    
      <h1 class="site-subtitle" itemprop="description"></h1>
    
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>
<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">


        
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
        


      
        
        <li class="menu-item menu-item-categories">


        
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
        


      
        
        <li class="menu-item menu-item-archives">


        
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
        


      
        
        <li class="menu-item menu-item-compass">


        
          <a href="/2017/01/11/compass" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th-list"></i> <br />
            
            compass中文手册
          </a>
        </li>
        


      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://sunhao.win/articles/css-top-right-bootom-left-zero.html">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Sun Hao">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.jpg">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Da'sBlog">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Da'sBlog" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                position:absolute-top,right,bottom,left为0使用
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-02-26T19:27:57+08:00">
                2017-02-26
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/css/" itemprop="url" rel="index">
                    <span itemprop="name">css</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a class="cloud-tie-join-count" href="/articles/css-top-right-bootom-left-zero.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count join-count" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o">本文总阅读量</i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>次
            </span>
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>  绝对定位一直用起来非常方便，直接脱离文本流。偶然发现它还有个超强的功能。竟然可以撑开盒子宽高。</p>
<h2 id="对外"><a href="#对外" class="headerlink" title="对外"></a>对外</h2><h3 id="默认情况下，看代码；盒子如果设置-宽高后-设置绝对定位-bottom为0会自动抵底部。"><a href="#默认情况下，看代码；盒子如果设置-宽高后-设置绝对定位-bottom为0会自动抵底部。" class="headerlink" title="默认情况下，看代码；盒子如果设置   宽高后   设置绝对定位,bottom为0会自动抵底部。"></a>默认情况下，看代码；盒子如果设置   宽高后   设置绝对定位,bottom为0会自动抵底部。</h3><p><img src="http://ojlt0g866.bkt.clouddn.com/blog/20170226/194602705.png" alt="mark"><br><figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">style</span>&gt;</span><span class="undefined"></span></div><div class="line">            .wai&#123;</div><div class="line">                position:relative;</div><div class="line">                top: 300px;</div><div class="line">                left: 300px;</div><div class="line">                width: 233px;</div><div class="line">                height: 370px;</div><div class="line">                background-color: yellow;</div><div class="line"></div><div class="line">            &#125;</div><div class="line">            .nei&#123;</div><div class="line">                position: absolute;</div><div class="line">                /*top: 0px;*/</div><div class="line">                /*left: 0px;</div><div class="line">                right: 0px;*/</div><div class="line">                bottom: 0px;</div><div class="line">                width: 100px;</div><div class="line">                height: 100px;</div><div class="line">                background-color: rgba(200,200,200,0.7);</div><div class="line">            &#125;</div><div class="line"></div><div class="line">        <span class="tag">&lt;/<span class="name">style</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line">     <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"wai"</span>&gt;</span></div><div class="line">             <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"nei"</span>&gt;</span></div><div class="line">                    <span class="comment">&lt;!--  &lt;div class="nei-item1"&gt;1&lt;/div&gt;</span></div><div class="line">                     &lt;div class="nei-item2"&gt;2&lt;/div&gt; --&gt;</div><div class="line">             <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">     <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure></p>
<a id="more"></a>
<h3 id="当我们同时设置bottom和top，nei盒子会自动抵触顶部。说明top优先级要比bottom高。"><a href="#当我们同时设置bottom和top，nei盒子会自动抵触顶部。说明top优先级要比bottom高。" class="headerlink" title="当我们同时设置bottom和top，nei盒子会自动抵触顶部。说明top优先级要比bottom高。"></a>当我们同时设置bottom和top，nei盒子会自动抵触顶部。说明top优先级要比bottom高。</h3><h3 id="当我们这个时候把nei盒子的高度去掉，这个时候神奇的事情发生了。nei的高度被撑开。"><a href="#当我们这个时候把nei盒子的高度去掉，这个时候神奇的事情发生了。nei的高度被撑开。" class="headerlink" title="当我们这个时候把nei盒子的高度去掉，这个时候神奇的事情发生了。nei的高度被撑开。"></a>当我们这个时候把nei盒子的高度去掉，这个时候神奇的事情发生了。nei的高度被撑开。</h3><p><img src="http://ojlt0g866.bkt.clouddn.com/blog/20170226/195039804.png" alt="mark"><br>同理width不设置，然后设置left,right为零，nei的宽度也会被撑开.</p>
<h3 id="为了确认宽高是来源于最邻近的定位点，而不是父级，我们在wai内在加个盒子wai2并设置宽高。"><a href="#为了确认宽高是来源于最邻近的定位点，而不是父级，我们在wai内在加个盒子wai2并设置宽高。" class="headerlink" title="为了确认宽高是来源于最邻近的定位点，而不是父级，我们在wai内在加个盒子wai2并设置宽高。"></a>为了确认宽高是来源于最邻近的定位点，而不是父级，我们在wai内在加个盒子wai2并设置宽高。</h3><p>1.nei盒子的宽高完全由上级定位节点，而不是父级确定。<br>2.nei盒子完全覆盖掉wai2的位置。<br><figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">style</span>&gt;</span><span class="xml"></span></div><div class="line">                          .wai&#123;</div><div class="line">                position:relative;</div><div class="line">                top: 300px;</div><div class="line">                left: 300px;</div><div class="line">                width: 233px;</div><div class="line">                height: 370px;</div><div class="line">                background-color: yellow;</div><div class="line"></div><div class="line">            &#125;</div><div class="line"></div><div class="line">                .wai2&#123;</div><div class="line">                width: 100px;</div><div class="line">                height: 100px;</div><div class="line">                background-color: yellow;</div><div class="line">                &#125;</div><div class="line">                 .nei&#123;</div><div class="line">                position: absolute;</div><div class="line">                top: 0px;</div><div class="line">                left: 0px;</div><div class="line">                right: 0px;</div><div class="line">                bottom: 0px;</div><div class="line">                background-color: red;</div><div class="line">                <span class="comment">&lt;!--background-color: rgba(200,200,200,0.7);--&gt;</span></div><div class="line">            &#125;</div><div class="line">        <span class="tag">&lt;/<span class="name">style</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line">     <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"wai"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"wai2"</span>&gt;</span></div><div class="line">                 <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"nei"</span>&gt;</span></div><div class="line"></div><div class="line">             <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">            </div><div class="line">     <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div></pre></td></tr></table></figure></p>
<p><img src="http://ojlt0g866.bkt.clouddn.com/blog/20170226/201040072.png" alt="mark"></p>
<h2 id="对内"><a href="#对内" class="headerlink" title="对内"></a>对内</h2><h3 id="假如nei盒子的内部有其余盒子呢，比如我们在内部加两个盒子-不设置宽度。只设置高度。宽度可以继承。"><a href="#假如nei盒子的内部有其余盒子呢，比如我们在内部加两个盒子-不设置宽度。只设置高度。宽度可以继承。" class="headerlink" title="假如nei盒子的内部有其余盒子呢，比如我们在内部加两个盒子 不设置宽度。只设置高度。宽度可以继承。"></a>假如nei盒子的内部有其余盒子呢，比如我们在内部加两个盒子 不设置宽度。只设置高度。宽度可以继承。</h3><h3 id="而且nei盒子的宽高-还是wai盒子的宽高。但是nei盒子的内部盒子的高度已经溢出。"><a href="#而且nei盒子的宽高-还是wai盒子的宽高。但是nei盒子的内部盒子的高度已经溢出。" class="headerlink" title="而且nei盒子的宽高 还是wai盒子的宽高。但是nei盒子的内部盒子的高度已经溢出。"></a>而且nei盒子的宽高 还是wai盒子的宽高。但是nei盒子的内部盒子的高度已经溢出。</h3><p><img src="http://ojlt0g866.bkt.clouddn.com/blog/20170226/201912871.png" alt="mark"></p>
<h3 id="当nei盒子的内部盒子设置百分比时候，是相对于父级。同理height也是相对父级。可以设置都是50-50-看下"><a href="#当nei盒子的内部盒子设置百分比时候，是相对于父级。同理height也是相对父级。可以设置都是50-50-看下" class="headerlink" title="当nei盒子的内部盒子设置百分比时候，是相对于父级。同理height也是相对父级。可以设置都是50% 50%看下"></a>当nei盒子的内部盒子设置百分比时候，是相对于父级。同理height也是相对父级。可以设置都是50% 50%看下</h3><p><img src="http://ojlt0g866.bkt.clouddn.com/blog/20170226/202907572.png" alt="mark"></p>
<p>总结来说。利用这个特性，我们内部无需再设置宽度。可直接继承。这样的好处可以实现响应式的变化。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/position/" rel="tag"># position</a>
          
            <a href="/tags/css/" rel="tag"># css</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/articles/safe-iptables.html" rel="next" title="使用iptables应对SYN攻击,CC攻击,ACK攻击[转]">
                <i class="fa fa-chevron-left"></i> 使用iptables应对SYN攻击,CC攻击,ACK攻击[转]
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/articles/safe-noun.html" rel="prev" title="名词 吞吐量 带宽 QPS TPS DDOS流量 并发用户数">
                名词 吞吐量 带宽 QPS TPS DDOS流量 并发用户数 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_cqq"></a>
  <a class="jiathis_button_douban"></a>
  <a class="jiathis_button_renren"></a>
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_kaixin001"></a>
  <a class="jiathis_button_copy"></a>
  <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
  var jiathis_config={
    hideMore:false
  }
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->

      
    </div>
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.jpg"
               alt="Sun Hao" />
          <p class="site-author-name" itemprop="name">Sun Hao</p>
          <p class="site-description motion-element" itemprop="description">Whoever wants to be first must be slave of all.</p>
        </div>
        <nav class="site-state motion-element">
        
          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">40</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">19</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              
                <span class="site-state-item-count">69</span>
                <span class="site-state-item-name">标签</span>
              
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#对外"><span class="nav-number">1.</span> <span class="nav-text">对外</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#默认情况下，看代码；盒子如果设置-宽高后-设置绝对定位-bottom为0会自动抵底部。"><span class="nav-number">1.1.</span> <span class="nav-text">默认情况下，看代码；盒子如果设置   宽高后   设置绝对定位,bottom为0会自动抵底部。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#当我们同时设置bottom和top，nei盒子会自动抵触顶部。说明top优先级要比bottom高。"><span class="nav-number">1.2.</span> <span class="nav-text">当我们同时设置bottom和top，nei盒子会自动抵触顶部。说明top优先级要比bottom高。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#当我们这个时候把nei盒子的高度去掉，这个时候神奇的事情发生了。nei的高度被撑开。"><span class="nav-number">1.3.</span> <span class="nav-text">当我们这个时候把nei盒子的高度去掉，这个时候神奇的事情发生了。nei的高度被撑开。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#为了确认宽高是来源于最邻近的定位点，而不是父级，我们在wai内在加个盒子wai2并设置宽高。"><span class="nav-number">1.4.</span> <span class="nav-text">为了确认宽高是来源于最邻近的定位点，而不是父级，我们在wai内在加个盒子wai2并设置宽高。</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#对内"><span class="nav-number">2.</span> <span class="nav-text">对内</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#假如nei盒子的内部有其余盒子呢，比如我们在内部加两个盒子-不设置宽度。只设置高度。宽度可以继承。"><span class="nav-number">2.1.</span> <span class="nav-text">假如nei盒子的内部有其余盒子呢，比如我们在内部加两个盒子 不设置宽度。只设置高度。宽度可以继承。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#而且nei盒子的宽高-还是wai盒子的宽高。但是nei盒子的内部盒子的高度已经溢出。"><span class="nav-number">2.2.</span> <span class="nav-text">而且nei盒子的宽高 还是wai盒子的宽高。但是nei盒子的内部盒子的高度已经溢出。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#当nei盒子的内部盒子设置百分比时候，是相对于父级。同理height也是相对父级。可以设置都是50-50-看下"><span class="nav-number">2.3.</span> <span class="nav-text">当nei盒子的内部盒子设置百分比时候，是相对于父级。同理height也是相对父级。可以设置都是50% 50%看下</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Sun Hao</span>
</div>


<div class="powered-by">
  Erstellt mit  <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

<div class="busuanzi-count">

  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user">本站访客数</i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span>人次</span>
  

  
    <span class="site-pv"><i class="fa fa-eye">本站总访问量</i><span class="busuanzi-value" id="busuanzi_value_site_pv"></span>次</span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  



  




	





  
    
    <script>
      var cloudTieConfig = {
        url: document.location.href, 
        sourceId: "",
        productKey: "68d47669d3794a958fbaaee9328b90f3",
        target: "cloud-tie-wrapper"
      };
    </script>
    <script src="https://img1.ws.126.net/f2e/tie/yun/sdk/loader.js"></script>
  







  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  


</body>
</html>
